<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>openttd.grfdb.GrfDB</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://openttd-python.googlecode.com">OpenTTD-Python</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="openttd-module.html">Package&nbsp;openttd</a> ::
        <a href="openttd.grfdb-module.html">Module&nbsp;grfdb</a> ::
        Class&nbsp;GrfDB
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="openttd.grfdb.GrfDB-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class GrfDB</h1><p class="nomargin-top"><span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB">source&nbsp;code</a></span></p>
<p>The GRF Database used for looking up names</p>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__init__"></a><span class="summary-sig-name">__init__</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Class constructor</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="openttd.grfdb.GrfDB-class.html#loadfromfile" class="summary-sig-name">loadfromfile</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">filename</span>)</span><br />
      Load the grf database from a file</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.loadfromfile">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="openttd.grfdb.GrfDB-class.html#savetofile" class="summary-sig-name">savetofile</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">filename</span>)</span><br />
      Save the grf database from a file</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.savetofile">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">boolean</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="openttd.grfdb.GrfDB-class.html#hasgrf" class="summary-sig-name">hasgrf</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">md5</span>)</span><br />
      Look a grf up in the database</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.hasgrf">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">int</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="openttd.grfdb.GrfDB-class.html#getdbcount" class="summary-sig-name">getdbcount</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Get the number of grfs in the database</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.getdbcount">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">list</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="openttd.grfdb.GrfDB-class.html#getgrfsnotinlist" class="summary-sig-name">getgrfsnotinlist</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">list</span>)</span><br />
      Get all grfs that are not in the database</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.getgrfsnotinlist">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="openttd.grfdb.GrfDB-class.html#addgrf" class="summary-sig-name">addgrf</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">id</span>,
        <span class="summary-sig-arg">md5</span>,
        <span class="summary-sig-arg">name</span>)</span><br />
      Add a grf to the databse</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.addgrf">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">string</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="openttd.grfdb.GrfDB-class.html#getgrfname" class="summary-sig-name">getgrfname</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">grf</span>)</span><br />
      Get a grfname from the database</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.getgrfname">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">list/None if not found</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="openttd.grfdb.GrfDB-class.html#addgrfinlist" class="summary-sig-name">addgrfinlist</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">list</span>,
        <span class="summary-sig-arg">grfid</span>)</span><br />
      Add the grf with grfid in the list to the database</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.addgrfinlist">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== INSTANCE VARIABLES ==================== -->
<a name="section-InstanceVariables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceVariables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">boolean</span>
    </td><td class="summary">
        <a name="canSaveLoad"></a><span class="summary-name">canSaveLoad</span> = <code title="True">True</code><br />
      set to False as soon as saving or loading failed, so we won't retry
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="openttd.grfdb.GrfDB-class.html#listchanged" class="summary-name">listchanged</a> = <code title="False">False</code><br />
      if the GRF database changed, i.e.
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">dict</span>
    </td><td class="summary">
        <a name="__database"></a><span class="summary-name">__database</span><br />
      The grf database
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">file</span>
    </td><td class="summary">
        <a name="file"></a><span class="summary-name">file</span><br />
      The grf database file
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="loadfromfile"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">loadfromfile</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">filename</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.loadfromfile">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Load the grf database from a file</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filename</code></strong> (string) - the filename to load from</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="savetofile"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">savetofile</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">filename</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.savetofile">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Save the grf database from a file</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filename</code></strong> (string) - the filename to save to</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="hasgrf"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">hasgrf</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">md5</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.hasgrf">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Look a grf up in the database</p>
  <dl class="fields">
    <dt>Returns: boolean</dt>
        <dd>If the database contains the grf</dd>
  </dl>
</td></tr></table>
</div>
<a name="getdbcount"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">getdbcount</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.getdbcount">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Get the number of grfs in the database</p>
  <dl class="fields">
    <dt>Returns: int</dt>
        <dd>Count of grfs in database</dd>
  </dl>
</td></tr></table>
</div>
<a name="getgrfsnotinlist"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">getgrfsnotinlist</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">list</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.getgrfsnotinlist">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Get all grfs that are not in the database</p>
  <p>Used for looking them up to the server</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>list</code></strong> (list) - list of grfs to check</li>
    </ul></dd>
    <dt>Returns: list</dt>
        <dd>all grfs not in the database</dd>
  </dl>
</td></tr></table>
</div>
<a name="addgrf"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">addgrf</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">id</span>,
        <span class="sig-arg">md5</span>,
        <span class="sig-arg">name</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.addgrf">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Add a grf to the databse</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>id</code></strong> (grfid) - the grfid</li>
        <li><strong class="pname"><code>md5</code></strong> (md5sum) - the md5sum</li>
        <li><strong class="pname"><code>name</code></strong> (string) - The grfname</li>
    </ul></dd>
  </dl>
<div class="fields">      <p><strong>Postcondition:</strong>
        listchanged is set to True
      </p>
</div></td></tr></table>
</div>
<a name="getgrfname"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">getgrfname</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">grf</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.getgrfname">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Get a grfname from the database</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>grf</code></strong> (list) - grf in list: [grfid, md5sum]</li>
    </ul></dd>
    <dt>Returns: string</dt>
        <dd>grf name</dd>
  </dl>
</td></tr></table>
</div>
<a name="addgrfinlist"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">addgrfinlist</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">list</span>,
        <span class="sig-arg">grfid</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="openttd.grfdb-pysrc.html#GrfDB.addgrfinlist">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Add the grf with grfid in the list to the database</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>list</code></strong> (list) - list of grfs</li>
        <li><strong class="pname"><code>grfid</code></strong> (grfid) - The grfid of the grf to add</li>
    </ul></dd>
    <dt>Returns: list/None if not found</dt>
        <dd>if found, a list with [grfid, md5sum, name], otherwise, None</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== INSTANCE VARIABLE DETAILS ==================== -->
<a name="section-InstanceVariableDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Variable Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceVariableDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="listchanged"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">listchanged</h3>
  if the GRF database changed, i.e. if anything needs to be saved
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
False
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://openttd-python.googlecode.com">OpenTTD-Python</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Mon Oct 20 13:03:11 2008
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
